//
// GPSMapEdit
// (c) Konstantin Galichsky (kg@geopainting.com), 2002-2004
//
// Select file to save with single filter.
//

# include "StdAfx.h"
# include "SaveFileDlg.h"
# include "Globals.h"

bool SaveFileDlg (const char * _strExt, const char * _strFilter, char _strFileName [MAX_PATH]) {
	if (_strFileName [0]) {
		string_t strExt = ".";
		strExt.append (_strExt);
		::PathRenameExtension (_strFileName, strExt.c_str ());
	}

	//
	// Ask file name.
	//
	OPENFILENAME ofn;
	::ZeroMemory (& ofn, sizeof (OPENFILENAME));
	ofn.lStructSize = sizeof (OPENFILENAME);
	ofn.hwndOwner = g_hWnd;
	ofn.hInstance = g_hResInst;
	ofn.lpstrFile = _strFileName;
	ofn.nMaxFile = MAX_PATH;
	ofn.lpstrDefExt = _strExt;
	ofn.nFilterIndex = 1;
	ofn.lpstrFilter = _strFilter;
	ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_ENABLESIZING | OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT;
	if (::GetSaveFileName (& ofn) == FALSE)
		return false;

	return true;
}